package com.mimose.cosy.proxy.api;


import com.mimose.cosy.proxy.enums.ProxyType;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author mimose
 * @description
 * @date 2021/4/24
 */
public class NoneProxy implements InvocationHandler, IProxy {
    private Object proxyTarget;

    public NoneProxy() {
    }

    @Override
    public ProxyType proxyType() {
        return ProxyType.NONE;
    }

    @Override
    public Object wrap(Object proxyTarget) {
        this.proxyTarget = proxyTarget;

        return this.proxyTarget;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        return method.invoke(this.proxyTarget, args);
    }

    @Override
    public void beforeInvoke(Method method, Object[] args) {
        // nothing
    }

    @Override
    public void afterInvoke(Object result, Method method, Object[] args) {
        // nothing
    }

    @Override
    public void afterThrowing(Throwable throwable, Method method, Object[] args) {
        // nothing
    }
}
